import subprocess
fp = open("out.txt", "w", encoding="UTF-8")
for i in range(1, 255):
    str1 = f"ping -c 1 192.168.0.{i}"
    a = subprocess.run(f"ping -c 1 192.168.0.{i}", shell=True)
    a1 = a.returncode
    print(a1)
    if a1 == 0:
        fp.write(str1 + "被使用"+'\n')
fp.close()
